﻿<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>Define an DirectProperty</Title>
      <Shortcut>directprop</Shortcut>
      <Description>Code snippet for a property using DirectProperty as the backing store</Description>
      <Author>Piero Castillo</Author>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Declarations>
        <Literal>
          <ID>type</ID>
          <ToolTip>Property Type</ToolTip>
          <Default>object</Default>
        </Literal>
        <Literal>
          <ID>property</ID>
          <ToolTip>Property Name</ToolTip>
          <Default>MyProperty</Default>
        </Literal>
        <Literal>
          <ID>ownerclass</ID>
          <ToolTip>The owning class of this Property.  Typically the class that it is declared in.</ToolTip>
          <Default>ownerclass</Default>
        </Literal>
        <Literal>
          <ID>default</ID>
          <ToolTip>Default Value</ToolTip>
          <Default>default</Default>
        </Literal>
      </Declarations>
      <Code Language="csharp">
        <![CDATA[
private $type$ _$property$;
public $type$ $property$
{
    get => _$property$;
    set => SetAndRaise($property$Property, ref _$property$, value);
}

public static readonly DirectProperty<$ownerclass$,$type$> $property$Property = 
    AvaloniaProperty.RegisterDirect<$ownerclass$,$type$>(nameof($property$), o => o.$property$, (o,v) => o.$property$ = v, $default$);

$end$]]>
      </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>